#include <iostream>
#include <sys/types.h>
#include <unistd.h>
using namespace std;

void Test1(){
  while(1)
  {
    pid_t pid = getpid();
    pid_t ppid = getppid();
    cout << "hello world!";
    cout << " pid:" << pid;
    cout << " ppid:" << ppid << endl;
    sleep(1);
  }
}

void Test2(){
  cout  << "I'm parent process:" << getpid() << endl;
  pid_t ret = fork();
  //下面的代码由父进程和子进程执行
  cout << "ret:" << ret << " ";
  cout << "pid:" << getpid() << " ";
  cout << "ppid:" << getppid() << endl;
}

int main(){
  Test2();
  return 0;
}
